<?php
class Gestion_newsletter_m extends Model{
      function Gestion_newsletter_m(){
          parent::Model();
          $this->load->database();
      }
       function get_all_newsletter($per_page,$offset){
            $this->db->select();
            $this->db->from('newsletter');
            $this->db->order_by('id','DESC');
            $this->db->limit($per_page,$offset);
            $query=$this->db->get();
            return $query->result_array();
        }
        function delete_newsletter($id){
            return $this->db->delete('newsletter',array('id'=>$id));
        }
        function get_newsletter($id){
    $query = $this->db->get_where('newsletter', array('id'=>$id));
         return $query;
      }
      function get_destination($table){
          $this->db->select('email');
          $this->db->from($table);
          $query=$this->db->get();
          return $query->result_array();
      }
      function add_newsletter($data){
           return $this->db->insert('newsletter',$data);
      }
      function update_newsletter($id,$data){
           return $this->db->update('newsletter',$data,array('id'=>$id));
      }
         function get_all_email($per_page,$offset){
            $this->db->select();
            $this->db->from('email');
            $this->db->order_by('id','DESC');
            $this->db->limit($per_page,$offset);
            $query=$this->db->get();
            return $query->result_array();
        }
         function add_email($data){
           return $this->db->insert('email',$data);
      }
      function delete_email($id){
            return $this->db->delete('email',array('id'=>$id));
        }
}
?>